package com.jf.listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-09-01
 * Time:22:26
 */
@WebListener
public class JFHttpSessionListener implements HttpSessionListener {
    @Override
    public void sessionCreated(HttpSessionEvent httpSessionEvent) {
        HttpSession session = httpSessionEvent.getSession();
        System.out.println("===================================================================================");
        System.out.println("session: " + session.getId() + " is created");
        System.out.println("===================================================================================");
        session.setMaxInactiveInterval(30);
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
        System.out.println("===================================================================================");
        System.out.println("session: " + httpSessionEvent.getSession().getId() + " is destroyed");
        System.out.println("===================================================================================");
    }
}
